package com.zfei.gfb.device;

import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import com.zfei.gfb.util.Strings;

/**
 * @author fgh
 */
public class RedisNames {

    /**
     * Utils
     */
    private static final Joiner JOINER = Joiner.on(":").useForNull(Strings.NULL);

    private static final Splitter SPLITTER = Splitter.on(":").trimResults();

    private static final Joiner JOINER_2 = Joiner.on("|").useForNull(Strings.NULL);

    private static final Splitter SPLITTER_2 = Splitter.on("|").trimResults();

    public static String join(Object... parts) {
        return JOINER.join(parts);
    }


    public static String join2(Object... parts) {
        return JOINER_2.join(parts);
    }


    /**
     * Tags
     */
    public static final String CACHE = "YX";

    public static final String VINFO = "VINFO";

    public static final String UID_VINFO = "UID_VINFO";

    public static final String TALK = "Talk";

    public static final String LIKE = "Like";

    public static final String REWARD = "reward";

    public static final String NEW_NOTIFY = "NewNotify";

    //关注公众号
    public static final String FOLLOW = "Follow";
    //关注用户
    public static final String FOLLOW_USER = "FollowUser";

    public static final String UID_SESSION_KEY = "uid_sid_key";

    public static final String UID_WEB_SESSION_KEY = "uid_web_sid_key";

    public static final String ENTRY_LIST = "EntryList";

    public static final String ENTRY_TIME = "EntryTime";

    public static final String NOTIFY = "notify";

    public static final String ACCOUNT_REWARD_RECORD = "account_reward";

    /**
     * Keys
     */
    public static String talkJoin(Object... parts) {
        return join(Lists.asList(TALK, parts).toArray());
    }

    public static String likeJoin(Object... parts) {
        return join(Lists.asList(LIKE, parts).toArray());
    }

    public static String rewardJoin(Object... parts) {
        return join(Lists.asList(REWARD, parts).toArray());
    }

    public static String followJoin(Object... parts) {
        return join(Lists.asList(FOLLOW, parts).toArray());
    }

    public static String followUserJoin(Object... parts) {
        return join(Lists.asList(FOLLOW_USER, parts).toArray());
    }

    public static String sessionJoin(String uid, int type) {
        return join2(UID_SESSION_KEY, uid, type);
    }

    public static String webSessionJoin(String uid, int type) {
        return join2(UID_WEB_SESSION_KEY, uid, type);
    }

    public static String notifyJoin(Object... parts) {
        return join(Lists.asList(NOTIFY, parts).toArray());
    }

    public static String UserVInfoJoin(Object... parts) {
        return join(Lists.asList(UID_VINFO, parts).toArray());
    }

    public static String accountRewardJoin(String uid, String toUid) {
        return join2(ACCOUNT_REWARD_RECORD, uid, toUid);
    }

    public static String latestNotify(Object... parts) {
        return join(Lists.asList(NEW_NOTIFY, parts).toArray());
    }
}
